<?php 
//公共函数
//是否登录，登录返回用户id，否则返回0
function is_login(){
	$user = session('user');
	if(!$user){
		return 0;
	}else{
		return $user['userid']?$user['userid']:0;
	}
}

//邮件发送
function send_mail($param) {
        $url = 'http://api.sendcloud.net/apiv2/mail/send';
        $API_USER = 'U37WJSPsGThg9lOs';
        $API_KEY = 'Va_Dly_test_Fyumqj';
        $param['apiUser'] = $API_USER;
        $param['apiKey'] = $API_KEY;
        $data = http_build_query($param);
        $options = array(
            'http' => array(
                'method' => 'POST',
                'header' => 'Content-Type: application/x-www-form-urlencoded',
                'content' => $data
        ));
        $context  = stream_context_create($options);
        $result = file_get_contents($url, FILE_TEXT, $context);
}



 ?>